cpu_weight parameter added to the xm create command. Minor bug fix for BVT.
unsigned int mem_kb,
const char *name,
int cpu,
+ float cpu_weight,
u32 *pdomid);
int xc_domain_pause(int xc_handle,
u32 domid);
u32 first_domid,
unsigned int max_doms,
xc_dominfo_t *info);
+int xc_domain_setcpuweight(int xc_handle,
+ u32 domid,
+ float weight);
int xc_shadow_control(int xc_handle,
u32 domid,
int xc_physinfo(int xc_handle,
xc_physinfo_t *info);
+int xc_sched_id(int xc_handle,
+ int *sched_id);
+
int xc_domain_setname(int xc_handle,
u32 domid,
char *name);
unsigned int mem_kb,
const char *name,
int cpu,
+ float cpu_weight,
u32 *pdomid)
{
int err;
op.u.createdomain.cpu = cpu;
if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
+ {
*pdomid = (u16)op.u.createdomain.domain;
+
+ err = xc_domain_setcpuweight(xc_handle, *pdomid, cpu_weight);
+ }
return err;
}
return do_dom0_op(xc_handle, &op);
}
+int xc_domain_setcpuweight(int xc_handle,
+ u32 domid,
+ float weight)
+{
+ int sched_id;
+ int ret;
+
+ /* Figure out which scheduler is currently used: */
+ if((ret = xc_sched_id(xc_handle, &sched_id)))
+ return ret;
+
+ switch(sched_id)
+ {
+ case SCHED_BVT:
+ {
+ u32 mcuadv;
+ int warpback;
+ s32 warpvalue;
+ long long warpl;
+ long long warpu;
+
+ /* Preserve all the scheduling parameters apart
+ of MCU advance. */
+ if((ret = xc_bvtsched_domain_get(xc_handle, domid, &mcuadv,
+ &warpback, &warpvalue, &warpl, &warpu)))
+ return ret;
+
+ /* The MCU advance is inverse of the weight.
+ Default value of the weight is 1, default mcuadv 10.
+ The scaling factor is therefore 10. */
+ if(weight > 0) mcuadv = 10 / weight;
+
+ ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv,
+ warpback, warpvalue, warpl, warpu);
+ break;
+ }
+
+ case SCHED_FBVT:
+ {
+ // TODO
+ break;
+ }
+ case SCHED_RROBIN:
+ {
+ /* The weight cannot be set for RRobin */
+ break;
+ }
+ case SCHED_ATROPOS:
+ {
+ /* TODO - can we set weights in Atropos? */
+ break;
+ }
+ }
+
+ return ret;
+}
+
+
int xc_domain_setinitialmem(int xc_handle,
u32 domid,
unsigned int initial_memkb)
/* XXX create domain on CPU=-1 so that in future it auto load ballances by default */
if ( xc_domain_create( xc_handle, nr_pfns * (PAGE_SIZE / 1024),
- name, -1, &dom ) )
+ name, -1, 1, &dom ) )
{
xcio_error(ioctxt, "Could not create domain. pfns=%d, %dKB",
nr_pfns,nr_pfns * (PAGE_SIZE / 1024));
unsigned int mem_kb = 0;
char *name = "(anon)";
int cpu = -1;
+ float cpu_weight = 1;
u32 dom = 0;
int ret;
- static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", NULL };
+ static char *kwd_list[] = { "dom", "mem_kb", "name",
+ "cpu", "cpu_weight", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisi", kwd_list,
- &dom, &mem_kb, &name, &cpu) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisif", kwd_list,
+ &dom, &mem_kb, &name, &cpu, &cpu_weight))
return NULL;
- if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
+ if ( (ret = xc_domain_create(
+ xc->xc_handle, mem_kb, name, cpu, cpu_weight, &dom)) < 0 )
return PyErr_SetFromErrno(xc_error);
return PyInt_FromLong(dom);
try:
self.name = sxp.child_value(config, 'name')
self.check_name(self.name)
+ self.cpu_weight = float(sxp.child_value(config, 'cpu_weight'))
self.memory = int(sxp.child_value(config, 'memory'))
if self.memory is None:
raise VmError('missing memory size')
memory = self.memory
name = self.name
cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
+ cpu_weight = self.cpu_weight
dom = self.dom or 0
- dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu)
+ dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu, cpu_weight= cpu_weight)
if dom <= 0:
raise VmError('Creating domain failed: name=%s memory=%d'
% (name, memory))
add_device_handler('pci', vm_dev_pci)
# Ignore the fields we already handle.
-add_config_handler('name', vm_field_ignore)
-add_config_handler('memory', vm_field_ignore)
-add_config_handler('cpu', vm_field_ignore)
-add_config_handler('console', vm_field_ignore)
-add_config_handler('image', vm_field_ignore)
-add_config_handler('device', vm_field_ignore)
-add_config_handler('backend', vm_field_ignore)
+add_config_handler('name', vm_field_ignore)
+add_config_handler('memory', vm_field_ignore)
+add_config_handler('cpu', vm_field_ignore)
+add_config_handler('cpu_weight', vm_field_ignore)
+add_config_handler('console', vm_field_ignore)
+add_config_handler('image', vm_field_ignore)
+add_config_handler('device', vm_field_ignore)
+add_config_handler('backend', vm_field_ignore)
# Register other config handlers.
fn=set_value, default=128,
use="Domain memory in MB.")
+gopts.var('cpu_weight', val='CPU_WEIGHT',
+ fn=set_value, default=1,
+ use="CPU weight.")
+
gopts.var('console', val='PORT',
fn=set_int, default=None,
use="Console port to use. Default is 9600 + domain id.")
config = ['vm',
['name', vals.name ],
- ['memory', vals.memory ] ]
+ ['memory', vals.memory ],
+ ['cpu_weight', vals.cpu_weight] ]
if vals.cpu:
config.append(['cpu', vals.cpu])
if vals.blkif:
ranfor = (u32)(now - d->lastschd);
mcus = (ranfor + MCU - 1)/MCU;
- return inf->avt + mcus;
+ return inf->avt + mcus * inf->mcu_advance;
}